package com.angel.arquitectura.service.impl.login;

import com.angel.arquitectura.dao.user.UserDAO;
import com.angel.arquitectura.exception.BusinessException;
import com.angel.arquitectura.model.user.User;
import com.angel.arquitectura.service.impl.GenericServiceImpl;
import com.angel.arquitectura.service.login.LoginService;

/**
 *
 * @author William
 */
public class LoginServiceImpl extends GenericServiceImpl implements LoginService{


    public User login(String userName, String password) {
        UserDAO userDAO = (UserDAO) super.getGenericDAO();
        User user = userDAO.findUniqueOrNullByUserNameAndPassword(userName, password);
        if(user == null){
            throw new BusinessException("User [" + userName + "] doesn't exist.");
        }
        return user;
    }
}